{% import "macro.html.twig" as web_macro %}

<form class="form-inline well well-sm " action="{{ path('open_course_manage_students',{id:course.id}) }}" method="get" novalidate>
  <div class="form-group col-md-7">
    <input class="form-control " type="text" style="width:45%" placeholder="{{ 'my.teaching.open_course.student_setting.enter_user_name'|trans }}" name="keyword" value="{{ app.request.get('keyword') }}">

    <input type="hidden" name="userType" value="login"/>

    {% if course.type == 'liveOpen' and setting('cloud_sms.sms_enabled') and (setting('cloud_sms.sms_live_play_one_day') == 'on' or setting('cloud_sms.sms_live_play_one_hour') == 'on') %}
      <select class="form-control" name="isNotified">
        {{ select_options({0:'my.teaching.open_course.student_setting.all_student'|trans, 1: 'my.teaching.open_course.student_setting.setting_remind_student'|trans }, app.request.get('isNotified')) }}
      </select>&nbsp;&nbsp;
    {% endif %}
    <button class="cd-btn cd-btn-primary">{{ 'form.btn.search'|trans }}</button>
  </div>
  <div class="clearfix"></div>
</form>

<table class="table table-striped" id="course-student-list">
  <thead>
    <tr>
      <th width="30%">{{'site.default.student'|trans}}</th>
      <th width="20%">{{'my.teaching.open_course.student_setting.recent_login'|trans}}</th>
      <th width="20%">{{'my.teaching.open_course.student_setting.phone_number'|trans}}</th>
      {% if course.type == 'liveOpen' and setting('cloud_sms.sms_enabled') and (setting('cloud_sms.sms_live_play_one_day') == 'on' or setting('cloud_sms.sms_live_play_one_hour') == 'on') %}
        <th>{{'my.teaching.open_course.student_setting.whether_remind'|trans}}</th>
      {% endif %}
      <th>{{'my.teaching.open_course.student_setting.operation'|trans}}</th>
    </tr>
  </thead>
  <tbody>
    {% for student in students %}
      {% set user = users[student.userId] %}
      <tr id="student-{{ user.id }}-tr">
        <td class="media" style="vertical-align: middle;">
          {{ web_macro.user_avatar(user, 'pull-left', 'avatar-sm') }}
          <a class="link-primary" target="_blank" href="{{ path('user_show', {id:user.id}) }}">{{ user.nickname }}</a>
          <div class="color-gray text-sm">{{'my.teaching.open_course.student_setting.join_time'|trans}}{{ student.createdTime|date('Y-n-d H:i') }}</div>
        </td>

        <td style="vertical-align: middle;">
          {{ student.lastEnterTime|date('Y-m-d H:i:s') }}
        </td>

        <td style="vertical-align: middle;">{{ student.mobile }}</td>

        {% if course.type == 'liveOpen' and setting('cloud_sms.sms_enabled') and (setting('cloud_sms.sms_live_play_one_day') == 'on' or setting('cloud_sms.sms_live_play_one_hour') == 'on') %}
          <td style="vertical-align: middle;">
            {% if student.isNotified %}{{'my.teaching.open_course.student_setting.whether_remind.yes'|trans}}{% else %}{{'my.teaching.open_course.student_setting.whether_remind.no'|trans}}{% endif %}
          </td>
        {% endif %}
        
        <td style="vertical-align: middle;">
          <div class="btn-group">
            {% if app.user.id != user.id %}
              <button class="btn btn-default btn-sm" data-toggle="modal" data-target="#modal" data-url="{{path('message_create', {toId:user.id})}}">{{'my.teaching.open_course.student_setting.send_message_btn'|trans}}</button>
            {% endif %}
            {% if app.user.isAdmin() %}
              <button class="btn btn-default btn-sm" data-toggle="modal" data-target="#modal" data-url="{{path('open_course_manage_students_show', {id:course.id, userId:user.id})}}">{{'my.teaching.open_course.student_setting.view_detail_btn'|trans}}</button>
            {% endif %}
          </div>
        </td>
      </tr>
    {% else %}
      <tr class="empty"><td colspan="20">{{'site.datagrid.empty'|trans}}</td></tr>
    {% endfor %}
  </tbody>
</table>


